home *** CD-ROM | disk | FTP | other *** search
- situation barracks
- vars
- send : integer;
- success : boolean;
- max : integer;
- hex : integer;
- in : squad;
-
- function max_in_barracks() : integer;
- vars
- total : integer;
- i : integer;
-
- begin
- total := 0;
- i := 1; // troop type 0 is colonist (which can't be sent down)
- while (i < 8) do
- begin
- total := total + Num_unit_type_barracks(This_barracks(), i);
- i := i + 1;
- end;
- if (total > 8) then
- total := 8;
- return total;
- end;
-
- function deploy_random_squad(number : integer) : none;
- vars
- success : boolean;
- type : integer;
-
- begin
- while (number > 0) do
- begin
- type := Random(7) + 1;
- success := Add_unit_to_squad(type);
- if success then
- number := number - 1;
- end;
- end;
-
- begin
- // first determine the total number of troops on board the fleet
- max := max_in_barracks();
- // Now determine if there are any troops already in the hex
- hex := Structure_hex(This_planet(), This_barracks());
- in := Hex_squad(This_planet(), hex);
- if (in <> nil) then
- begin
- if ((max + Num_units(in)) > 8) then
- max := 8 - Num_units(in);
- end;
- if (max > 0) then
- begin
- send := Random(max) + 1;
- deploy_random_squad(send);
- success := Deploy_squad();
- end;
- end;
-